﻿function MenuItemControl(panelName, requestDataUrl) {
    var self = this;

    self.menuItemSelector = "#" + panelName;

    self.menuItemTabSelector = "#" + panelName + "-tab";

    self.requestDataUrl = requestDataUrl;

    self.IsLoaded = false;

    $(self.menuItemSelector).click(function () {
        self.Reload();
    });

    self.Reload = function() {
        $.ajax({
            url: self.requestDataUrl,
            type: 'GET',
            dataType: 'html',
            success: function (data) {
                $(self.menuItemTabSelector).html(data);
                self.menuItemSelector.IsLoaded = true;
            },
            error: function (e) {
                alert(e);
            }
        });
    }
}